<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .father {
            position: relative;
            display: inline-block;
            width: 60px;
            height: 30px;
        }

        .son input {
            display: none;
        }

        .son {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: 0.5s;
        }

        .son::before {
            position: absolute;
            content: '';
            height: 20px;
            width: 20px;
            left: 5px;
            bottom: 5px;
            background-color: white;
            transition: 0.5s;
        }

        input:checked+.son {
            background-color: #2196F3;
        }

        input:focus+.son {
            box-shadow: 0 0 1px #2196F3;
        }

        input:checked+.son::before {
            transform: translateX(30px);
        }

        .round {
            border-radius: 20px;
        }

        .round::before {
            border-radius: 50%;
        }
    </style>
</head>

<body>
    <label class="father">
        <input type="checkbox" name="" id="">
        <div class="son"></div>
    </label>
    <label class="father">
        <input type="checkbox" name="" id="">
        <div class="son round"></div>
    </label>
</body>

</html>